<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>商户注册 - 未央店</title>
<link rel="stylesheet" href="css/layout.css" type="text/css" />
<link rel="stylesheet" href="css/shanghu_reg_layout.css" type="text/css" />
<link rel="shortcut icon" href="images/favicon.ico" />
<script type="text/javascript" src="js/jquery_1.7.1.js"></script>
<script type="text/javascript" src="js/plugin_validate_js/jquery.validate.js"></script>
<script type="text/javascript" src="js/plugin_validate_js/jquery.validate.messages_cn.js"></script>
<script type="text/javascript" src="js/httpclient.js"></script>
<script type="text/javascript" src="js/json2.js"></script>
<script type="text/javascript" src="js/shanghu_reg_validate.js"></script>

</head>

<body>
<div id="wrap">
<div id="container">
    <div id="header">
	  <div id="logo">
	    <a href="http://127.0.0.1"><img src="images/jiayi_logo.jpg" width="200px" height="75px" alt="logo" style="margin-top:15px; border:0px;"/></a>
	  </div>
	</div>
	
	<div id="main">
	  <div id="left">
	  <h2>新商户注册</h2>
	  以下均为必填
	  
	  <form name="reg" action="shanghu_reg.php" method="post" id="reg">
	      <p>您的邮箱：（即为您的登录账户，请填写正确的邮箱）</p><input class="box" type="text" name="Email" id="email_account"/>
		  <br /><br />
          <p>您的商户名称：（50字以内，以后还可以修改）</p><input class="box" type="text" name="partyname" id="partyname"/>
          <br /><br />
          <p>设个密码：（6~16位，区分大小写）</p><input id="password" class="box" type="password" name="password" />
		  <br /><br />
		  <p>重复密码：</p><input class="box" type="password" name="password_again" />
		  <br /><br />
          <p>字符验证：（若看不清，点击图片换一张）</p><input class="vali" type="text" name="vali" size="4"/>&nbsp;&nbsp;
		  <img src="ValidateCode.php" alt="验证码" width="50" height="20" vspace="6" align="absmiddle" onclick='this.src="ValidateCode.php?"+new Date().getTime()' />
		  <br /><br />
		  <input type="submit" id="button" name="submit" value="同意协议，注册吧" agreement="checked" email_account="checked"/>
		  
      </form>
	    <br />
		<div style="float:left;">
		<input type="checkbox" checked id="agreement" style="margin: 1px 0px 0px 0px; float:left;"/><span style="float:left; margin-left:5px;">同意<a class="bkchange" target="_blank" href="http://127.0.0.1/about.php?item=5">《未央店网服务协议》</a></span>
	    </div>
	  </div>
	  
	  <div id="right">
	    <h2>已有帐号？</h2>
		<h3><a class="bkchange" href="/shanghu_login.php">立即登录</a></h3>
		<ul style="display:none;">
		  <li>使用其它帐号登录：</li>
		  <li><a href=# class="sina">新浪微博</a></li>
		  <li><a href=# class="tb">淘宝账号</a></li>
		  <li><a href=# class="ten">腾讯微博</a></li>
          <li><a href=# class="ren">人人网</a></li>
		</ul>
	  </div>
	  
	</div>
	
	
	<div id="footer">
	  <ul>
		<li><a href="http://127.0.0.1/about.php?item=0" target=_blank>关于我们</a>|</li>
		<li><a href="http://127.0.0.1/about.php?item=1" target=_blank>联系我们</a>|</li>
		<li><a href="http://127.0.0.1/about.php?item=2" target=_blank>推广服务</a>|</li>
		<li><a href="http://127.0.0.1/about.php?item=3" target=_blank>人才招聘</a>|</li>
		<li><a href="http://127.0.0.1/about.php?item=4" target=_blank>友情链接</a></li>
      </ul>
	  <br />
      Copyright(c) 2013 weiyangdian.com All Rights Reserved
	</div>

 </div>
 </div>
</body>
</html>

<?php
function jumpto($url)
{
    echo "<script type=text/javascript>";   
    echo "window.location.href=$url";   
    echo "</script>";
}

?>
<?php   //这段php是提交后才会运行，处理提交数据的。
require_once(dirname(__FILE__)."/../include/httpclient.php");


//用来接收用户的注册信息。并跟control层交互
if( isset( $_POST['submit'] ) )  //说明用户提交了。
{
	//首先判断验证码有没有错
	session_start();					
	if(!empty($_SESSION["VCODE"]))
	{
		$v_valid_server = strtolower($_SESSION["VCODE"]);
		if( isset($_POST['vali']))
		{
			$v_valid_client = strtolower($_POST['vali']);

			if($v_valid_server!= $v_valid_client)//不相等，说明客户端验证码输入错误
			{
			echo '<script type="text/javascript">';
			echo 'alert("验证码错误，请重新输入");';
			echo '</script>';
			exit();
			}
		    //else 相等，验证码正确，继续往下走。

		}
		else//$_POST['vali']没传过来，无法判断验证码
		{
			echo '<script type="text/javascript">';
			echo 'alert("验证码没有传过来，请重新输入");';
			echo '</script>';
			exit();
		}
	}
	else//session发生错误。
	{
		echo '<script type="text/javascript">';
		echo 'alert("session VCODE发生错误，请重新输入");';
		echo '</script>';
		exit();
	}

	$arg = array( 'act' => 'insert_party_reg',
		          'email_account' => $_POST['Email'],
		          'partyname' => stripslashes($_POST['partyname']),
		          'password' => md5($_POST['password'])
		        );
	$arg['partyname']= urlencode($arg['partyname']);

	$r = call_serviceurl( 23,  $arg);
	
	if( $r == true ) //数据插入成功
	{
		session_start();
		
		$_SESSION['email_account'] = $arg['email_account'];
		$_SESSION['isRegLoginOk'] = 'OK';
		$_SESSION['lasttime'] = time();

		echo '<script type="text/javascript">';
        echo 'setTimeout("location=\'http://127.0.0.1:8001/shanghu_page_edit.php\'");';
        echo '</script>';
		exit();
		//header("location:http://www.baidu.com");
	}
	else  //数据没插入成功
	{
		echo '<script type="text/javascript">';
        echo 'setTimeout("location=\'./exception.php\'");';
        echo '</script>';
		exit();
		//header("location:http://www.google.com");
	}

}
?>

<script type="text/javascript">
function judgeCookie()
{
	var isCookie=navigator.cookieEnabled?true:false;
	if( ! isCookie )//说明浏览器cookie未启动
		alert( "您浏览器的 cookie 功能被禁用，请启用此功能。否则将有可能发生未知错误或无法登录注册。" );
}
function setFocus( focus_element )
{
	document.getElementById( focus_element ).focus();
}
window.onload = judgeCookie;
window.onload = function() { setFocus("email_account");};

</script>